/*
    Project Milestone 3
    by Lorenzo Miori [Lorenzo.Miori@stud-inf.unibz.it,
    Matteo Angriman [Matteo.Angriman@stud-inf.unibz.it],
    Nick Preda [Nicolae.Preda@stud-inf.unibz.it]
*/

import DB.BookingDB;
import DB.DatabaseLogin;
import GUI.MainMenuGUI;

public class HotelDBClientMain {
	
	private static DatabaseLogin connectGUI;
	private static final int EXIT_STATUS_ERROR = 1;
	
	public static void main(String[] args)
	{

		connectGUI = new DatabaseLogin("Hotel Database Client");
		/* Show the frame and WAIT for Connect! button press */
		connectGUI.showFrame(true, true);
		
		if (connectGUI.dbConnect() == null)
		{
			System.err.println("LOGIN: erroneus login OR login abort.");
			System.exit(EXIT_STATUS_ERROR);
		}
                System.out.println(new BookingDB(connectGUI.getConnection()).getTableData());
                /* Set something important to do at exit! */
                Runtime.getRuntime().addShutdownHook(new Thread() {
                    @Override
                    public void run() {
                        System.out.println("Shutting down server connection...");
                        connectGUI.closeConnection();
                    }
                });
                
                /* Let's start with the GUI ;) */
                new MainMenuGUI();
	}

}